package cn.jhc.servlet;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.jhc.dao.NewUserDao;
@WebServlet(name="Add New User",urlPatterns={"/addnewuser.do"})
public class AddNewUserServlet extends HttpServlet {
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
		throws ServletException, IOException {
	req.setCharacterEncoding("UTF-8");
	String name =(String)req.getParameter("name");
	String password =(String)req.getParameter("password");
	String displayname =(String)req.getParameter("displayname");
	String email =(String)req.getParameter("email");
	String phone = req.getParameter("phone");
	String vote = "no";
	NewUserDao u=new NewUserDao();
	u.addNewUser(name, password, displayname,email,phone,vote);
	RequestDispatcher dispatcher = req.getRequestDispatcher("/login.jsp");
	dispatcher.forward(req, resp);
}
}
